<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script src="/html/util.js"></script>
    <script>
        var channelId = getQuery("id")
        window.onload=function () {
            findByItem()
        }

        function findByItem(pageNo) {
            axios.get("/post/findByItem",{
                params:{
                    channelId,
                    pageNo,
                    name:$("title").value,
                    user:$("user").value,
                    startDate:$("startDate").value,
                    endDate:$("endDate").value
                }
            }).then(e => {
                var info = e.data;
                var str = null;
                for (var i = 0;i < info.list.length;i++){
                    var obj = info.list[i];
                    str += `<tr>
                                <td><a href="/html/reply.html?id=${obj.name}">${obj.name}</a></td>
                                <td>${obj.user}</td>
                                <td>${obj.replyNum}</td>
                                <td>${obj.date}</td>
                            </tr>`;
                }
                $("bodyData").innerHTML = str;


                var pageStr = "";
                for (var i = 1; i <= info.pages;i++){
                    pageStr += `<a href="javascript:findByItem(${i})">${i} </a>`
                }
                $("pageDiv").innerHTML = pageStr;
            })
        }
    </script>
</head>
<body>
    <table border="1" cellspacing="0" width="50%">
        <thead>
            <tr>
                <th>主题</th>
                <th>作者</th>
                <th>发帖时间</th>
                <th>回帖数量</th>
            </tr>
            <tbody id="bodyData"></tbody>
        </thead>
    </table><br>
    <div id="pageDiv"></div>
    主贴名称：<input type="text" id="title"><br>
    发帖人：<input type="text" id="user"><br>
    起始时间：<input type="datetime-local" id="startDate"><br>
    结束时间：<input type="datetime-local" id="endDate"><br>
    <input type="button" value="搜索" onclick="findByItem(1)">
    <a href="add.html">添加</a>
</body>
</html>